package main

import (
	_ "github.com/go-sql-driver/mysql"
	"github.com/jsoq/goblog/app/http/middlewares"
	"github.com/jsoq/goblog/bootstrap"
	"github.com/jsoq/goblog/pkg/config"
	"net/http"
)


func init() {
	// 初始化配置信息
	config.Initialize()
}

func main() {

	bootstrap.SetupDB()
	router := bootstrap.SetupRoute()

    // 自定义 404 页面
	// router.NotFoundHandler = http.HandlerFunc(notFoundHandler)
	//router.NotFoundHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
	//	w.WriteHeader(http.StatusNotFound)
	//	fmt.Fprint(w, "<h1>请求页面未找到 :(</h1><p>如有疑惑，请联系我们。</p>")
	//})
    http.ListenAndServe(":"+config.GetString("app.port"), middlewares.RemoveTrailingSlash(router))
}